package hprose.hello.client;

import hprose.client.HproseHttpClient;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HelloClient {
    public static void main(String[] args) throws IOException {
    	sayHello();
    	sayHello2();
    	sayHello3();
    	sayHello4();
    }
    
    public static void sayHello() throws IOException{
        HproseHttpClient client = new HproseHttpClient();
        client.useService("http://localhost/rosebus/Hello");
        String result = client.invoke("sayHello", new Object[] { "@andot" }, String.class);
        System.out.println(result);
    }
    
    public static void sayHello2() throws IOException{
        HproseHttpClient client = new HproseHttpClient();
        client.useService("http://localhost/rosebus/Hello");
        Map<String, String> inMap = new HashMap<String, String>();
        inMap.put("a", "a2");
        inMap.put("b", "b2");
        Map<String, String> outMap = client.invoke("sayHello2", new Object[] { inMap}, HashMap.class);
        System.out.println(outMap);
    }
    
    public static void sayHello3() throws IOException{
        HproseHttpClient client = new HproseHttpClient();
        client.useService("http://localhost/rosebus/Hello");
        Map<String, Object> inMap = new HashMap<String, Object>();
        inMap.put("a", "a3");
        Map<String, Object> outMap =  client.invoke("sayHello3", new Object[] { inMap, 100}, HashMap.class);
        System.out.println(outMap);
    }
    
    public static void sayHello4() throws IOException{
        HproseHttpClient client = new HproseHttpClient();
        client.useService("http://localhost/rosebus/Hello");
        List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("a", "a4");
        list.add(map1);
        List<Map<String, Object>> outList = client.invoke("sayHello4", new Object[] {list}, ArrayList.class);
        for (Map<String, Object> map : outList) {
			System.out.println(map);
		}
    }
}
